package main

import (
	"bytes"
	"encoding/json"
	"fmt"
)

func main() {
	i := 0
	for i < 10 {
		i++
		BigTest4()
	}
}

func BigTest() {
	str := ` {"extension":"das","orderID":2436739151240888340}`
	//t := &Test{}
	t := make(map[string]interface{}, 0)
	err := json.Unmarshal([]byte(str), &t)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(t)
}

func BigTest1() {
	str := ` {"extension":"fadas","orderID":2436739151240888340}`
	buf := bytes.NewBuffer([]byte(str))
	d := json.NewDecoder(buf)
	d.UseNumber()
	t := make(map[string]interface{}, 0)
	err := d.Decode(&t)
	if err != nil {
		fmt.Println(err)
		return
	}
	s2, err := json.Marshal(t)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(s2))
}

func BigTest2() {
	str := `{"data":{"extension":"","orderID":2436739151240888340}}`
	buf := bytes.NewBuffer([]byte(str))
	d := json.NewDecoder(buf)
	d.UseNumber()
	t := make(map[string]map[string]interface{}, 0)
	err := d.Decode(&t)
	if err != nil {
		fmt.Println(err)
		return
	}
	s2, err := json.Marshal(t)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(s2))
}

func BigTest3() {
	str := `{"data":{"extension":"","orderID":15555555551}}`
	buf := bytes.NewBuffer([]byte(str))
	d := json.NewDecoder(buf)
	d.UseNumber()
	t := make(map[string]map[string]interface{}, 0)
	err := json.Unmarshal([]byte(str), &t)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(t)
}

func BigTest4() {
	str := `{"data":{"extension":"","orderID":1}}`
	buf := bytes.NewBuffer([]byte(str))
	d := json.NewDecoder(buf)
	d.UseNumber()
	t := make(map[string]map[string]interface{}, 0)
	err := json.Unmarshal([]byte(str), &t)
	if err != nil {
		fmt.Println(err)
		return
	}
	switch t["data"]["orderID"].(type) {
	case float64:
		fmt.Println("11111")
	case int64:
		fmt.Println("???")
	}
	fmt.Println(t)
}

type Test struct {
	Extension string
	OrderID   int64
}

func baseTest() {
	c := Cla{123}
	s := &Stud{Name: "ss", Age: 18}
	x := append(s.Clas, c)
	s.Clas = x
	res, err := json.Marshal(s)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(string(res))
}

type Stud struct {
	Name string
	Age  int
	Clas []Cla
}
type Cla struct {
	Id int
}
